#include <event2/event.h>
#include <stdio.h>
#include <signal.h>

static int n_calls = 0;
void cb_func(evutil_socket_t fd, short what, void *arg)
{
    printf("cb_func called %d times so far.\n", ++n_calls);
}

void run(struct event_base *base)
{
    struct event *hup_event;
    struct timeval tv = { 100, 0 };
    hup_event = evsignal_new(base, SIGHUP, cb_func, NULL);
//     evsignal_add(hup_event, &tv); // 使用timeout
    evsignal_add(hup_event, NULL);// 不使用
    event_base_dispatch(base);
}

int main(){
    struct event_base *base = event_base_new();
    run(base);
    return 0;
}
